﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class YijieProxy
{
    private static YijieProxy _instance = new YijieProxy();

    public static YijieProxy Instance { get { return _instance; } }

    private SiumingPayHelper _helper;

    private YijieProxy() { }

    #region 对外接口
    public void Init()
    {
        var go = new GameObject("SiumingHelper");
        _helper = go.AddComponent<SiumingPayHelper>();
    }

    public void Login(Action<bool, string> callBack)
    {
        _helper.LoginCallback = callBack;
        _helper.Login();
    }

    public void LogOut(Action<bool, string> callBack)
    {
        _helper.LogoutCallback = callBack;
        _helper.LogOut();
    }

    //price价钱 100 = 1元 
    //乐嗨嗨要求最少一元
    //count 数量
    //回调返回值 "1":没有登陆 "-1":未知原因 
    //成功时,返回值为订单号
    public void Charge(string name, int price, Action<bool, string> callBack)
    {
        _helper.PayCallback = callBack;
        _helper.Charge(name, price, 1);
    }

    public void RequestHistoryOrder(Action<bool, string> callBack)
    {
        _helper.HistoryOrderCallback = callBack;
    }

    //用于同步order信息
    //向服务器发送信息,告诉服务器这些订单客户端已经发放了.
    public void SyncOrderGived(string orderId)
    {
        _helper.SyncClientOrderGived(orderId);
    }
    #endregion
}
